﻿@{
    Layout = null;
    var Path = ViewBag.Data as System.Data.DataTable;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Edit</title>
    <link href="~/Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" />
    <link href="~/Scripts/ligerUI/skins/ligerui-icons.css" rel="stylesheet" />
    <link href="~/Scripts/ligerUI/skins/Gray/css/all.css" rel="stylesheet" />
    <link href="~/Content/css/common.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.10.2.min.js" type="text/javascript"></script>
    <script src="~/Scripts/ligerUI/js/ligerui.all.js"></script>
    <script src="~/Scripts/common.js"></script>
    <style>
        .gridtable {
            width: 400px;
            margin: 0px;
        }

            .gridtable td {
                height: 30px;
                line-height: 30px;
            }
    </style>
</head>
<body>
    <div style="margin:10px 0px;">
        <table class="gridtable">
            <tr>
                <td style="text-align:right; width:100px;">
                    质控项名称：
                </td>
                <td>
                    <input type="text" id="txtQualityPointTitle" class="l-text" style="width:250px;" value="@Path.Rows[0]["QualityPointTitle"]" /><font style="color:red;">&nbsp;*</font>
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    超时比对项：
                </td>
                <td>
                    @*<input type="text" id="txtComparePointTitle" style="width:250px;" value="@Path.Rows[0]["ComparePointTitle"]" />*@
                    <select id="selComparePointTitle" name="selComparePointTitle" >
                        <option id="" value="" title=""></option>
                    </select>
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    超时时长：
                </td>
                <td>
                    <input type="number" class="l-text" width="50px" id="txtOverTime" value="@Path.Rows[0]["OverTime"]" />分钟
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    是否启用：
                </td>
                <td>
                   
                    <input type="radio" name="Status" class="l-radio" title="是" value="1" @(Path.Rows[0]["Status"].ToString() == "1" ? "checked" : "") />是&nbsp;&nbsp;<input type="radio" class="l-radio" name="Status" title="否" value="0" @(Path.Rows[0]["Status"].ToString() == "0" ? "checked" : "") />否
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    排序：
                </td>
                <td>
                    <input type="text" id="txtSort" style="width:50px;" class="l-text" value="@Path.Rows[0]["Sort"]" />
                </td>
            </tr>
            @*<tr>
                <td style="text-align:right; width:100px;">
                    备注：
                </td>
                <td style="padding-top: 5px;">
                    <textarea id="txtRemarks" rows="5" class="l-textarea" maxlength="500" style="padding:5px;width:240px;"></textarea>
                </td>
            </tr>*@
            <tr>
                <td colspan="2" style="text-align:center;padding-top:10px;">
                    <input id="btnSubmit" type="button" value="确定" class="l-button" style="background: skyblue;" onclick="save()" />&nbsp;&nbsp;&nbsp;
                    <input id="btnCancel" type="button" value="取消" class="l-button" onclick="closeDialog()" />
                </td>
            </tr>
            <tr></tr>
        </table>
        <input type="hidden" id="hdnId" value="@(Path.Rows[0]["Id"])" />
    </div>
    <script type="text/javascript">
        $(function () {
            GetAllPoint();

            $(".l-dialog-close").click(function () {
                parent.window.location.reload();
            });
        });

        function closeDialog() {
            parent.window.location.reload();
            frameElement.dialog.close();//关闭dialog
        }

        function save() {
            if ($("#txtPathWayName").val() == "")
            { $("#txtPathWayName").focus(); return; }
            var editurl = "../QualityPoint/EditSubmit";
            $.post(editurl, {
                rnd: new Date().getMilliseconds(),
                QualityPointTitle: $("#txtQualityPointTitle").val(),
                //ComparePointTitle: $("#selComparePointTitle").val(),
                ComparePointId: $("#selComparePointTitle").val(),
                OverTime: $("#txtOverTime").val(),
                Sort: $("#txtSort").val(),
                Status: $("input[name='Status']:checked").val(),
                Id: $("#hdnId").val()
            }, function (data) {
                alert(data);
            })
        }

        function GetAllPoint() {
            $.ajax({
                url: '/TraumaCenter/QualityPoint/GetAllPoint?ram=' + Math.random(),
                cache: false,
                success: function (data) {
                    var jsonData = $.parseJSON(data);
                    
                    var strVar = "";
                    for (var i = 0; i < jsonData.length; i++) {
                        var check = '';
                        if (jsonData[i].ComparePointId != null && jsonData[i].ComparePointId != '' && jsonData[i].ComparePointId != undefined && jsonData[i].ComparePointId.toString() == $("#hdnId").val()) {
                            check = "checked";
                        }
                        else
                            check = '';

                        strVar += "<option id='" + jsonData[i].Id + "' value='" + jsonData[i].Id + "' title='" + jsonData[i].Id + "' " + check + ">" + jsonData[i].QualityPointTitle + "</option>";
                    }
                    $("#selComparePointTitle").html(strVar);
                },
                error: function () {
                    $.ligerDialog.error("程序错误");
                }
            });
        }
    </script>
</body>
</html>
